<template>
	<page-body>
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center flex_0_ibhf"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub fd0_0_ibhf'>
					<view class='flex flex-wrap align-center fd0_0_c0_ibhf' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">
						<text class='fu-iconfont2  fd0_0_c0_c0_ibhf'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='fd0_0_c1_c0_ibhf'>{{classhourName}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-end fd0_0_c0_ibhf'>
					</view>
				</view>
			
			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<view class="" >
				
				<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout list_flex_2_ibhf"  v-if="listyxt.length>0 && isup">
					<view class='flex flex-direction flex-wrap align-stretch list_fd2_0_ibhf' v-for="(items,indexs) in listyxt" :key='indexs'>
						<view class='flex flex-wrap align-center list_fd2_0_c0_ibhf'>
							<text>{{indexs + 1}}</text>
							<view class='flex flex-wrap align-center list_fd2_0_c0_c1_ibhf'>
								<text class='list_fd2_0_c0_c1_c0_ibhf'>{{type==2?items.question_type_name:items.type_name}}</text>
							</view>
						</view>
						<view class='flex flex-wrap align-center'>
							<text v-html="type==2?items.question_title:items.title"></text>
						</view>
					</view>
					
				</view>
				<view v-if="listyxt.length==0 && isup">
					<slot>
						<view class="public-page-empty">
							<image src='/static/global/order.png'></image>
							<view class="txt">暂无数据</view>
						</view>
					</slot>
				</view>
			</view>
			<!---flex布局flex布局结束-->
			<view 
				class="flex flex-direction flex-wrap align-center justify-center benben-position-layout flex list_flex_3_ibhf">
				<button class='list_fd3_0_ibhf' @tap.stop="jump">一键发布</button>

			</view>
			<view :style="{height: '88rpx'}"></view>


		</view>
	</page-body>
</template>
<script>
	import {
		mdToHtml
	} from '@/common/utils/mdParser.js'
	export default {
		components: {},


		data() {
			return {
				isup:false,
				tab: 2,
				"fd2_0_c1_c0_c1": 2,
				"fd2_0_c1_c1_c1": 2,
				"fd2_1_c1_c0_c1": 2,
				"fd2_1_c1_c1_c1": 2,
				"analyse": "",

				"classname": "",
				"classhourName": "",
				"datum": "",
				"aid": "687",
				lessonplanning_id: "210",
				list: [],
				listyxt:[],//
				"tabsInfofd1_0": {
					lineleft: '',
					lineWidth: '',
					moveX: 0,
					scrollX: 0,
					PageScrollX: 0,
					isInit: false
				},
				course:'',//课程id
				type:2,//1课前预习  2课后作业 3课程考试
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			let {
				id,
				aid,
				name,
				name2,
				course
			} = options
			if (id != undefined) this.lessonplanning_id = id
			if (name != undefined) this.classhourName = name
			if (name2 != undefined) this.classname = name2
			if (aid != undefined) this.aid = aid
			if (course != undefined) this.course = course
			this.type=options.type
			this.getyxlist(2)
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// ai分析
			aianalyse(id, name) {
				this.list.forEach(item => {
					item.show = false
					if (item.aid == id) {
						item.show = true
					}
				})
				this.get662c96aab794d(name)
				this.$forceUpdate()
			},

			async get662c96aab794d(name) {
				this.analyse = ""
				let data662c96aab794d = await this.$api.post(global.apiUrls.post68c910fcdbef9, {
					agent_id:'62',
					query: `针对一名学生，在进行课前预习时，请针对课程【${this.classname}】内【${this.classhourName}】下的【${name}】进行分析，指导学生进行预习`
				})
				if (data662c96aab794d.data.code != 1) {
					this.$message.info(data662c96aab794d.data.msg);
					return
				}
				let info662c96aab794d = data662c96aab794d.data.data
				this.analyse = mdToHtml(info662c96aab794d.choices[0].message.content)
				this.$forceUpdate()
			},
			// 获取课前预习知识点
			async getlist(key) {
				this.isup=false
				this.tab=1
				let data6690ebae3b794 = await this.$api.post(global.apiUrls.post68cbd5d51c6e7, {
					homework_id: this.lessonplanning_id
				})
				this.isup=true
				if (data6690ebae3b794.data.code != 1) {
					this.$message.info(data6690ebae3b794.data.msg);
					return
				}
				let info6690ebae3b794 = data6690ebae3b794.data.data
				console.log("data6690ebae3b794=>", info6690ebae3b794)
				this.list = info6690ebae3b794
				this.list.forEach(item => {
					item.show = false
					item.ny=item.difficulty=='beginner'?1:item.difficulty=='intermediate'?3:5
				})
			},
			// 
			async getyxlist(key){
				this.tab=2
				let url=global.apiUrls.post68de4b1f5b9c8
				if(this.type==3){
					url=global.apiUrls.post672a00eacf230
				}
				let data6690ebae3b794 = await this.$api.post(url, {
					homework_id: this.lessonplanning_id,
					exampaper_id:this.lessonplanning_id,
				})
				this.isup=true
				if (data6690ebae3b794.data.code != 1) {
					this.$message.info(data6690ebae3b794.data.msg);
					return
				}
				let info6690ebae3b794 = data6690ebae3b794.data.data
				console.log("data6690ebae3b794=>", info6690ebae3b794)
				this.listyxt = info6690ebae3b794
				this.listyxt.forEach(item => {
					item.show = false
					item.ny=item.difficulty=='beginner'?1:item.difficulty=='intermediate'?3:5
				})
				console.log(this.listyxt)
			},
			// 预习测试
			async navs() {
				// 查看预习测试有没有发布
				let res = await this.$api.post(global.apiUrls.post669e09ab2af21, {
					teaching_id: this.aid,
					type: 1
				})

				if (res.data.code != 1) {
					this.$message.info(res.data.msg);
					return
				}

				uni.navigateTo({
					url: "/pages/kc/answer/answer?teaching_id=" + this.aid
				})
			},
			jump(){
				uni.redirectTo({
					url:'/pages/kc/teacherfbyx/teacherfbyx?id='+this.lessonplanning_id+'&course='+this.course+'&type='+this.type
				})
			}
		}
	};
</script>
<style lang="scss" scoped>
	.tab-outer {
		z-index: 99;
	}

	.checkTitlefd1_0_ibhf {
		font-weight: 700 !important;
		font-size: 28rpx !important;
		color: #333 !important;
		background-color: rgba(255, 255, 255, 1) !important;
	}

	.linefd1_0_ibhf {
		width: 40rpx;
		height: 8rpx;
		top: 80rpx;
		background: #145efd;
		background-size: 100% auto !important;
		border-radius: 4rpx;
	}

	.page {
		width: 100vw;
		height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
		overflow: hidden;
		position: relative;
	}


	.prepare_linefd1_0 {
		background: #145efd;
		width: 50rpx;
		height: 8rpx;
		top: 80rpx;
		background-size: 100% auto !important;
	}

	.checkTitlefd1_0 {
		font-weight: 700 !important;
		font-size: 28rpx !important;
		color: #333 !important;
	}

	::v-deep .prepare_benbenTabsfd1_0 {
		width: 750rpx;
		height: 90rpx;
		white-space: nowrap;
		text-align: center;
	}

	.prepare_flex_2 {
		padding: 15rpx 24rpx 32rpx 24rpx;
		height: calc(100vh - 280rpx);
		overflow: hidden;
		overflow-y: auto;
	}

	::v-deep .prepare_fd2_0_c2_c1 {
		width: 100%;
	}

	.prepare_fd2_0_c2_c0_c0 {
		color: rgba(20, 94, 253, 1);
		line-height: 40rpx;
		font-weight: 500;
		font-size: 28rpx;
	}

	.prepare_fd2_0_c2 {
		background: #f3f6f8;
		background-size: 100% auto;
		border-radius: 16rpx;
		padding: 24rpx;
	}

	.prepare_star1fd2_0_c1_c1_c1 {
		width: 24rpx;
		height: 24rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 5rpx 0rpx 5rpx;
	}

	.prepare_star1fd2_0_c1_c0_c1 {
		height: 24rpx;
		margin: 0rpx 5rpx 0rpx 5rpx;
		width: 24rpx;
	}

	.prepare_star1fd2_0_c1_c0_c1 {
		width: 24rpx;
		height: 24rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 5rpx 0rpx 5rpx;
	}

	.prepare_fd2_0_c1_c0_c0 {
		margin: 0rpx 16rpx 0rpx 0rpx;
		color: rgba(153, 153, 153, 1);
		font-size: 24rpx;
	}

	.prepare_fd2_0_c1 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.prepare_fd2_0_c0_c2 {
		width: 28rpx;
		height: 28rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.prepare_fd2_0_c0_c1 {
		color: #333;
		font-size: 28rpx;
		font-weight: 500;
		line-height: 48rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.prepare_fd2_0_c0_c0 {
		color: #333;
		font-size: 28rpx;
		font-weight: 500;
		line-height: 48rpx;
	}

	.prepare_fd2_0_c0 {
		margin: 0rpx 0rpx 18rpx 0rpx;
	}

	.prepare_fd2_0 {
		background: var(--benbenbgColor1);
		margin: 0rpx 0rpx 24rpx 0rpx;
		border-radius: 16rpx;
		background-size: 100% auto;
		padding: 32rpx 24rpx 32rpx 24rpx;
	}




	.prepare_flex_4 {
		width: 750rpx;
		height: 110rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		left: 0rpx;
		border-radius: 0rpx;
	}

	.prepare_fd4_0 {
		background: #4781f5;
		width: 100%;
		line-height: 110rpx;
		font-size: 32rpx;
		color: #fff;
		border-radius: 0rpx;
	}

	::v-deep .benbenTabsfd1_0_ibhf {
		width: 750rpx;
		height: 90rpx;
		white-space: nowrap;
		background: #fff;
		text-align: center;
	}

	.list_flex_2_ibhf {
		padding: 24rpx;
		padding-bottom: 0;

		.list_fd2_0_ibhf {
			padding: 24rpx;
			background-color: #ffffff;
			// border-bottom: 1px solid #eee;
			border-radius: 16rpx;
			margin-bottom: 24rpx;

			.list_fd2_0_c0_ibhf {
				margin: 0rpx 0rpx 12rpx 0rpx;

				.list_fd2_0_c0_c1_ibhf {
					background: #5695F7;
					height: 40rpx;
					border-radius: 8rpx;
					padding: 0rpx 10rpx 0rpx 10rpx;
					margin: 0rpx 0rpx 0rpx 20rpx;

					.list_fd2_0_c0_c1_c0_ibhf {
						color: var(--benbenFontColor3);
						font-size: 24rpx;
						line-height: 40rpx;
					}
				}
			}
		}
	}

	.prepafre_fd2_0 {
		background-color: #fff;
		margin-bottom: 24rpx;
		border-radius: 16rpx;
		padding: 24rpx 24rpx 0;
	}

	.list_flex_3_ibhf {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(88rpx + var(--window-bottom));

		.list_fd3_0_ibhf {
			border-radius: 12rpx;
			width: 702rpx;
			line-height: 84rpx;
			font-size: 24rpx;
			background: #145EFD;
			color: #fff;
			height: 84rpx;
		}
	}
	.flex_0_ibhf {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background: #fff;
		background-size: 100% auto !important;
	
		.fd0_0_ibhf {
			padding: 0rpx 32rpx 0rpx 32rpx;
	
			.fd0_0_c1_c0_ibhf {
				font-size: 36rpx;
				font-weight: 700;
				color: #333333;
				line-height: 50rpx;
			}
		}
	}
	
	.fd0_0_c0_ibhf {
		width: 120rpx;
	
		.fd0_0_c0_c0_ibhf {
			font-size: 36rpx;
			color: #333;
		}
	}
	.public-page-empty {
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
		padding: 120upx 0 0 0;
	
		image {
			width: 300rpx;
			height: 300rpx;
		}
	
		.txt {
			font-size: 28upx;
			color: $uni-text-color;
			text-align: center;
			line-height: 100upx;
			color: var(--benben-loading-color, #999999);
		}
	
		.loadTips {
			line-height: 30upx;
		}
	
		.btn {
			width: 260upx;
			height: 78upx;
			line-height: 78upx;
			background: linear-gradient(309deg, rgba(254, 49, 0, 1) 0%, rgba(255, 90, 16, 1) 100%);
			opacity: 1;
			border-radius: 44upx;
			font-size: 28upx;
			color: #fff;
			text-align: center;
			margin-top: 100upx;
		}
	}
</style>
